package cn.baiyang.rocketmq.spring.autoconfigure.ratelimit;

import org.springframework.boot.autoconfigure.condition.AllNestedConditions;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

/**
 * RocketMQ Producer RateLimit Config Condition
 *
 * @author hongzhu
 * @version V1.0
 * @since 2024-03-14 11:38
 */
public class RateLimitCondition extends AllNestedConditions {

    public RateLimitCondition() {
        super(ConfigurationPhase.REGISTER_BEAN);
    }

    @ConditionalOnProperty(prefix = "rocketmq-java", value = {"endpoints", "producer.topics"})
    static class ProducerConfigExistsCondition {
    }

    @ConditionalOnProperty(prefix = "rocketmq-java", value = {"producer.enable-rate-limit"}, havingValue = "true", matchIfMissing = true)
    static class RateLimitConfigExistsCondition {
    }
}
